import request from '@/utils/http'
import { BaseResult, PageResult } from '@/types/axios'
import { CereAgreement, GetAgreementByIdParams } from './model/versionModel'
import { AppVersion, GetAppVersionParams } from './model/appVersionModel'

export class VersionService {
  // 根据ID获取协议内容
  static getById(params: GetAgreementByIdParams) {
    return request.get<BaseResult<PageResult<CereAgreement>>>({
      url: 'appVersions/getById',
      params
    })
  }

  // 新增协议
  static addAgreement(data: CereAgreement) {
    return request.post<BaseResult<any>>({
      url: 'appVersions/addAgreement',
      data
    })
  }

  // 删除协议
  static deleteAgreement(contentId: number) {
    return request.del<BaseResult<any>>({
      url: `appVersions/del/${contentId}`
    })
  }

  // 修改协议
  static updateAgreement(data: CereAgreement) {
    return request.post<BaseResult<any>>({
      url: 'appVersions/updateAgreement',
      data
    })
  }

  // 获取app版本分页数据
  static getAppVersionPage(params: GetAppVersionParams) {
    return request.get<BaseResult<PageResult<AppVersion>>>({
      url: 'appVersions/getPage',
      params
    })
  }

  // 新增app版本
  static addAppVersion(data: AppVersion) {
    return request.post<BaseResult<any>>({
      url: 'appVersions/add',
      data
    })
  }

  // 删除app版本
  static deleteAppVersion(id: number) {
    return request.del<BaseResult<any>>({
      url: `appVersions/${id}`
    })
  }

  // 更新app版本
  static updateAppVersion(data: AppVersion) {
    return request.post<BaseResult<any>>({
      url: 'appVersions/update',
      data
    })
  }
}